package com.zf.shuashua.ui.mine;


import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.widget.Toolbar;

import com.tencent.bugly.beta.Beta;
import com.zf.shuashua.R;
import com.zf.shuashua.api.Constants;
import com.zf.shuashua.base.BaseActivity1;

public class AboutActivity extends BaseActivity1 implements View.OnClickListener {
    private Toolbar mToolbar;
    private TextView mTvTitle;
    private TextView tvVersion;
    private TextView tvVersion1;
    private LinearLayout llToCD;
    private LinearLayout llToEmail;
    private LinearLayout llToUpdate;

    @Override
    protected void initView() {
        mToolbar = findViewById(R.id.toolbar);
        mTvTitle = findViewById(R.id.tv_title);
        initToolBar(mToolbar, true, "");
        mTvTitle.setText("关于长豆");

        tvVersion = findViewById(R.id.tvVersion);
        tvVersion1 = findViewById(R.id.tvVersion1);

        llToCD = findViewById(R.id.llToCD);
        llToEmail = findViewById(R.id.llToEmail);
        llToUpdate = findViewById(R.id.llToUpdate);

        llToCD.setOnClickListener(this);
        llToEmail.setOnClickListener(this);
        llToUpdate.setOnClickListener(this);
        tvVersion.setText(getVersionName());
        tvVersion1.setText("当前版本：" + getVersionName());

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_about;
    }

    /**
     * 复制字符串
     *
     * @param text
     */
    private void toCopy(String text) {
        ClipboardManager mClipboardManager = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
        mClipboardManager.setPrimaryClip(ClipData.newPlainText(null, text));
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.llToCD:
                startActivity(new Intent(this, MineH5Activity.class).putExtra("money", Constants.H5_CD).putExtra("title", "长豆官网"));
                break;
            case R.id.llToEmail:
                toCopy("tangmx@changdou.vip");
                Toast.makeText(this, "复制成功", Toast.LENGTH_SHORT).show();
                break;
            case R.id.llToUpdate://检查更新app
                Beta.checkUpgrade();
                break;

        }
    }
}
